package com.ynwt.test;

import com.ynwt.domain.User;
import com.ynwt.repository.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by huangying on 2017/5/25.
 */
@Component
public class UserThread extends Thread {

    private String openid;

    public UserThread setOpenid(String openid) {
        this.openid = openid;
        return this;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        User user = userDao.findOne(openid);
//        User user = userDao.findOne("oy2qbv67T1gybw8pzvNS1f7ptBvU");
        System.out.println(user);
        System.out.println("user thread. user id = " + 1);//todo 换成下面那一句
//        System.out.println("user thread. user id = " + user.getId());
    }

    @Autowired
    private UserDao userDao;
}
